package com.rongmai.web.ctrl;

import com.rongmai.db.enums.UserRoleEnum;
import com.rongmai.db.model.BaseResult;
import com.rongmai.db.model.User;
import com.rongmai.db.vo.UserVo;
import com.rongmai.web.bo.RecommendBo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@Slf4j
@RestController
@RequestMapping("/recommend")
public class RecommendCtrl {

    @Resource
    private RecommendBo recommendBo;

    /**
     * 推荐-投资人
     * @return
     */
    @RequestMapping("getInvestUser")
    public BaseResult<List<UserVo>> getInvestUser() {
        return BaseResult.succ(recommendBo.getRecommendUser(UserRoleEnum.INVEST));
    }

    /**
     * 推荐-融资人
     * @return
     */
    @RequestMapping("getFinanceUser")
    public BaseResult<List<UserVo>> getFinanceUser() {
        return BaseResult.succ(recommendBo.getRecommendUser(UserRoleEnum.FINANCE));
    }

    @RequestMapping("getRecommendUser")
    public BaseResult<List<UserVo>> getRecommendUser(String role) {
        return BaseResult.succ(recommendBo.getRecommendUser(UserRoleEnum.get(role)));
    }


    @RequestMapping(value="/company_user", method = RequestMethod.GET)
    public BaseResult<List<UserVo>> myCompanyUser(Integer companyId){
        try {
            return BaseResult.succ(recommendBo.myCompanyUser(companyId));
        } catch (Exception e) {
            log.error("搜索异常", e);
        }
        return BaseResult.FAIL;
    }
}
